package util;

import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.dom4j.DocumentException;

public abstract class PatternParser {
Map<String,Set<Enum>> patternTypeMap;
	
	public PatternParser(){
		patternTypeMap = new HashMap<String,Set<Enum>>();
	}
	public Map<String,Set<Enum>> parse(List<String> filenames) throws DocumentException, ClassNotFoundException{
		return parse(filenames.toArray(new String[filenames.size()]));
	}
	
	abstract public Map<String,Set<Enum>> parse(String... filenames) throws DocumentException, ClassNotFoundException;

	protected void addPatternType(String name, Enum e){
		if(patternTypeMap.containsKey(name)){
			Set<Enum> enumList  = patternTypeMap.get(name);
			enumList.add(e);
		}else{
			Set<Enum> enumList = new HashSet<Enum>();
			enumList.add(e);
			patternTypeMap.put(name, enumList);
		}
	}
}
